﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace StockholmsStad.Windows.UI.Infrastructure.Converters
{
    public class BoolToStringConverter : IValueConverter
    {        
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType != typeof(string))
                throw new InvalidOperationException("The target must be a string");

            if ((bool)value)
                return "Ja";

            var param = parameter as string;
            if (!string.IsNullOrEmpty(param))
            {
                var returnFalse = Boolean.Parse(param);
                if (returnFalse)
                    return "Nej";
            }
            return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}
